<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="org.hibernate.Session"%>
<%@page import="pe.lucene.web.myrating.HibernateUtil"%>
<%@page import="pe.lucene.web.myrating.Player"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Process Log on</title>
</head>
<meta http-equiv="refresh" content="2;url=../index.jsp">
<body>

<%
Session hbSession = null;

try {
    hbSession = HibernateUtil.currentSession();
    String id = request.getParameter("id");
    String passwd = request.getParameter("passwd");
    
    Player player = (Player) hbSession.get(Player.class, id);
    
    out.println("player:" + player);
    
    if (player == null) {
        out.println("Non-exist I");
    } else {
    	if (player.getPasswd().equals(passwd)) {
    		out.println("Welcome " + player.getId());
            player.setLogged(true);
            session.setAttribute("player", player);
    	} else {
    	    out.println("Wrong password!");
    	}
    }
    
} catch (Exception ex) {
    out.println("exception/" + ex.getMessage());
} finally {
    HibernateUtil.closeSession();
}

%>

</body>
</html>